﻿using BluntArchitecture.Core;
using BluntArchitecture.Core.DataInterfaces;
using BluntArchitecture.Data;
using System.Collections.Generic;
using System.Web.Mvc;

namespace BluntArchitecture.Controllers
{
    public class CustomerController : Controller
    {
        private ICustomerDao _CustomerDao;

        /// <summary>
        /// This constrcutor would be unecessary with a proper dependency injection tool.
        /// The other constructor would be called and the implementation of the ICustomerDao
        /// interface would be automatically injected.  But since we aren't using a dependency
        /// injection tool, we're going to manually construct a CustomerDao object.
        /// </summary>
        public CustomerController()
        {
            _CustomerDao = new CustomerDao();
        }

        public CustomerController(ICustomerDao customerDao)
        {
            _CustomerDao = customerDao;
        }

        public ViewResult Index()
        {
            ViewData["Title"] = "Customers";

            IList<Customer> customers = _CustomerDao.GetAllCustomers();

            return View(customers);
        }
    }
}
